   * ******************************************************************** *
   * ******************************************************************** *
   *                                                                      *
   *               Community-based Monitoring in Angolan Schools          *
   *               MASTER DO_FILE                                         *
   *                                                                      *
   * ******************************************************************** *
   * ******************************************************************** *

       /*
       ** OUTLINE:      PART 0: Standardize settings and install packages
                        PART 1: Set globals for dynamic file paths
                        PART 2: Set globals for constants and varlist
                               used across the project. Install all user-contributed
                               commands needed.
                        PART 3: Call the task-specific master do-files
                               that call all dofiles needed for that
                               task. Do not include Part 0-2 in a task-
                               specific master do-file


       ** IDS VAR:              school_id

       ** WRITTEN BY:           Stefan Leeffers

       ** Last date modified:   8 Mar 2023
       */


   * ******************************************************************** *
   *
   *       PART 0:  INSTALL PACKAGES AND STANDARDIZE SETTINGS
   *
   *           - Install packages needed to run all dofiles called
   *            by this master dofile.
   *           - Use ieboilstart to harmonize settings across users
   *
   * ******************************************************************** *


   *Install all packages that this project requires:
   local user_commands ietoolkit estout coefplot
   foreach command of local user_commands {
       cap which `command'
       if _rc == 111 {
           ssc install `command'
       }
   }

   ado update ietoolkit estout coefplot, update


   *Standardize settings accross users
   ieboilstart, version(14.1)
   `r(version)'

   set seed 20190723

   * ******************************************************************** *
   *
   *       PART 1:  PREPARING FOLDER PATH GLOBALS
   *
   *           - Set the global box to point to the project folder
   *            on each collaborator's computer.
   *           - Set other locals that point to other folders of interest.
   *
   * ******************************************************************** *

   * Users
   * -----------

   *User Number:
   * Stefan                  1
   * Next User               2

   *Set this value to the user currently using this file
   global user  1

   * Root folder globals
   * ---------------------

   if $user == 1 {
       global projectfolder "/Users/stefanleeffers/Dropbox/Documents/Research/Projects/AO CBM"
   }

   if $user == 2 {
       global projectfolder ""  // Enter the file path to the project folder for the next user here
   }

   * Project folder globals
   * ---------------------

   global dataWorkFolder         "$projectfolder/DataWork"

   global mastData               "$dataWorkFolder/MasterData"

   global encryptFolder          "$dataWorkFolder/EncryptedData"

   *Baseline folder globals
   global Baseline               "$dataWorkFolder/Baseline"

     *Encrypted round sub-folder globals
     global Baseline_encrypt       "$encryptFolder/Round Baseline Encrypted"
     global Baseline_dtRaw         "$Baseline_encrypt/Raw Identified Data"
     global Baseline_doImp         "$Baseline_encrypt/Dofiles Import"
     global Baseline_HFC           "$Baseline_encrypt/High Frequency Checks"

     *DataSets sub-folder globals
     global Baseline_dt            "$Baseline/DataSets"
     global Baseline_dtDeID        "$Baseline_dt/Deidentified"
     global Baseline_dtInt         "$Baseline_dt/Intermediate"
     global Baseline_dtFin         "$Baseline_dt/Final"

     *Dofile sub-folder globals
     global Baseline_do            "$Baseline/Dofiles"
     global Baseline_doCln         "$Baseline_do/Cleaning"
     global Baseline_doCon         "$Baseline_do/Construct"
     global Baseline_doAnl         "$Baseline_do/Analysis"

     *Output sub-folder globals
     global Baseline_out           "$Baseline/Output"
     global Baseline_outRaw        "$Baseline_out/Raw"
     global Baseline_outFin        "$Baseline_out/Final"

     *Questionnaire sub-folder globals
     global Baseline_prld          "$Baseline_quest/PreloadData"
     global Baseline_doc           "$Baseline_quest/Questionnaire Documentation"


   *Endline folder globals
   global Endline                "$dataWorkFolder/Endline"

     *Encrypted round sub-folder globals
     global Endline_encrypt        "$encryptFolder/Round Endline Encrypted"
     global Endline_dtRaw          "$Endline_encrypt/Raw Identified Data"
     global Endline_doImp          "$Endline_encrypt/Dofiles Import"
     global Endline_HFC            "$Endline_encrypt/High Frequency Checks"

     *DataSets sub-folder globals
     global Endline_dt             "$Endline/DataSets"
     global Endline_dtDeID         "$Endline_dt/Deidentified"
     global Endline_dtInt          "$Endline_dt/Intermediate"
     global Endline_dtFin          "$Endline_dt/Final"

     *Dofile sub-folder globals
     global Endline_do             "$Endline/Dofiles"
     global Endline_doCln          "$Endline_do/Cleaning"
     global Endline_doCon          "$Endline_do/Construct"
     global Endline_doAnl          "$Endline_do/Analysis"

     *Output sub-folder globals
     global Endline_out            "$Endline/Output"
     global Endline_outRaw         "$Endline_out/Raw"
     global Endline_outFin         "$Endline_out/Final"

     *Questionnaire sub-folder globals
     global Endline_prld           "$Endline_quest/PreloadData"
     global Endline_doc            "$Endline_quest/Questionnaire Documentation"


   *Intervention folder globals
   global Intervention           "$dataWorkFolder/Intervention"

     *Encrypted round sub-folder globals
     global Intervention_encrypt   "$encryptFolder/Round Intervention Encrypted"
     global Intervention_dtRaw     "$Intervention_encrypt/Raw Identified Data"
     global Intervention_doImp     "$Intervention_encrypt/Dofiles Import"
     global Intervention_HFC       "$Intervention_encrypt/High Frequency Checks"

     *DataSets sub-folder globals
     global Intervention_dt        "$Intervention/DataSets"
     global Intervention_dtDeID    "$Intervention_dt/Deidentified"
     global Intervention_dtInt     "$Intervention_dt/Intermediate"
     global Intervention_dtFin     "$Intervention_dt/Final"

     *Dofile sub-folder globals
     global Intervention_do        "$Intervention/Dofiles"
     global Intervention_doCln     "$Intervention_do/Cleaning"
     global Intervention_doCon     "$Intervention_do/Construct"
     global Intervention_doAnl     "$Intervention_do/Analysis"

     *Output sub-folder globals
     global Intervention_out       "$Intervention/Output"
     global Intervention_outRaw    "$Intervention_out/Raw"
     global Intervention_outFin    "$Intervention_out/Final"

     *Questionnaire sub-folder globals
     global Intervention_prld      "$Intervention_quest/PreloadData"
     global Intervention_doc       "$Intervention_quest/Questionnaire Documentation"


   * Set all non-folder path globals that are constant accross
   * the project. Examples are conversion rates used in unit
   * standardization, different sets of control variables,
   * adofile paths etc.

   do "$dataWorkFolder/global_setup.do"


   * ******************************************************************** *
   *
   *       PART 3: - RUN DOFILES CALLED BY THIS MASTER DOFILE
   *
   *           - When survey rounds are added, this section will
   *            link to the master dofile for that round.
   *           - The default is that these dofiles are set to not
   *            run. It is rare that all round-specfic master dofiles
   *            are called at the same time; the round specific master
   *            dofiles are almost always called individually. The
   *            exception is when reviewing or replicating a full project.
   *
   * ******************************************************************** *


   **Set the locals corresponding to the tasks you want
   * run to 1. To not run a task, set the local to 0.
   local importcleanDo_baseline       1
   local constructDo_baseline         1
   local importcleanDo_endline        1
   local constructDo_endline          1
   local analysisDo_endline           1
   local cleaningDo_intervention      1
   local analysisDo_intervention      1

   if (`importcleanDo_baseline' == 1) { // Change the local above to run or not to run this file
       do "$Baseline_doImp/Baseline_import_MasterDofile.do"
   }

   if (`constructDo_baseline' == 1) { // Change the local above to run or not to run this file
       do "$Baseline_do/Baseline_construct_MasterDofile.do"
   }

   if (`importcleanDo_endline' == 1) { // Change the local above to run or not to run this file
       do "$Endline_doImp/Endline_import_MasterDofile.do"
   }

   if (`constructDo_endline' == 1) { // Change the local above to run or not to run this file
       do "$Endline_do/Endline_construct_MasterDofile.do"
   }

   if (`analysisDo_endline' == 1) { // Change the local above to run or not to run this file
       do "$Endline_do/Endline_analysis_MasterDofile.do"
   }

   if (`cleaningDo_intervention' == 1) { // Change the local above to run or not to run this file
       do "$Intervention_do/Intervention_cleaning_MasterDofile.do"
   }

   if (`analysisDo_intervention' == 1) { // Change the local above to run or not to run this file
       do "$Intervention_do/Intervention_analysis_MasterDofile.do"
   }







*
*
* * * * END OF DOFILES * * * *
